package tests.page;

import common.Utils;
import org.openqa.selenium.By;

import java.io.IOException;


/**
 * Created with IntelliJ IDEA.
 * Description: 登录界面
 * User: Spider-Man
 * Date: 2025-09-20
 * Time: 14:28
 */
public class LoginPage extends Utils{
    public static final String url = "http://43.143.179.59:8080/blogin.html";


    //登录页面是否正常渲染
    public void loginPageRight() throws IOException {
        driver.get(url);
        /**
         * 密码登录
         */
        String expect = driver.findElement(By.cssSelector("body > div > div.login-container.col-sm-6.col-md-6.col-lg-5.col-xl-5 > div.tab-box > span.active.tab-span")).getText();
        assert expect.equals("密码登录");
        expect = driver.findElement(By.cssSelector("#loginForm > div:nth-child(1) > label")).getText();
        assert expect.equals("手机号");
        expect = driver.findElement(By.cssSelector("#loginForm > div:nth-child(2) > label")).getText();
        assert expect.equals("密码");
        expect = driver.findElement(By.cssSelector("#loginForm > button")).getText();
        assert expect.equals("登录");
        getScreenShot(getClass().getName());

        /**
         * 验证码登录
         */
        driver.findElement(By.cssSelector("body > div > div.login-container.col-sm-6.col-md-6.col-lg-5.col-xl-5 > div.tab-box > span.tab-span.active")).click();
        driver.findElement(By.cssSelector("body > div > div.login-container.col-sm-6.col-md-6.col-lg-5.col-xl-5 > div.tab-box > span:nth-child(2)"));
        driver.findElement(By.cssSelector("#codeForm > div:nth-child(1) > label"));
        driver.findElement(By.cssSelector("#codeForm > div:nth-child(2) > label"));
        driver.findElement(By.cssSelector("#getVerificationCode"));
        driver.findElement(By.cssSelector("#codeForm > button"));
        driver.findElement(By.cssSelector("body > div > div.login-container.col-sm-6.col-md-6.col-lg-5.col-xl-5 > div.register-link > a")).getAttribute("#href");
        getScreenShot(getClass().getName());
    }


}
